<?php
$servername = "l192.168.56.103"; // MySQL 主机名
$username = "root"; // MySQL 用户名
$password = "123456"; // MySQL 密码
$dbname = "myDB"; // 要连接的数据库名称

// 创建连接
$link = new mysqli($servername, $username, $password, $dbname); 
echo $link?'数据库连接成功':'数据库连接失败';
mysqli_query($link,"set names utf8");
$id = $_POST['id'];
$student_id = $_POST['student_id'];
$username = $_POST['username'];
$xingbie = $_POST['xingbie'];
$birthday = $_POST['birthday'];
$class = $_POST['class'];
$major = $_POST['major'];
$query = "update students set major='{$major}',class='{$class}',student_id='{$student_id}',name='{$username}',sex='{$xingbie}',birthday='{$birthday}' where id={$id}";
$result = mysqli_query($link,$query);
if($result){
	echo "<script>alert('修改成功');window.location.href='index.php'</script>";
}
else{
	echo "<script>alert('修改失败');window.location.href='index.php'</script>";
}
?>

